// pages/song-list/song-list.js

Page({

  /**
   * 页面的初始数据
   */
  data: {
    toView: 'green',
    songlist: [{
      classify: "推荐",
      child: [{
        "images": "../../resource/images/song-list-1.jpg",
        "title": "行在路上 寻找旅途的秘境",
        "time": "130万"
      }, {
        "images": "../../resource/images/song-list-2.jpg",
        "title": "网易云那些10至100w+评论的歌单按专辑排序",
        "time": "1953万"
      }, {
        "images": "../../resource/images/song-list-3.jpg",
        "title": "一起努力 做更好的自己",
        "time": "59.3亿"
      }, {
        "images": "../../resource/images/song-list-4.jpg",
        "title": "两个人互相惦念的见面才有意义",
        "time": "953万"
      }, {
        "images": "../../resource/images/song-list-5.jpg",
        "title": "神仙翻唱：超好听的女生翻唱集鸭",
        "time": "2072万"
      }]
    }, {
      classify: "官方",
      child: [{
        "images": "../../resource/images/song-list-1.jpg",
        "title": "行在路上 寻找旅途的秘境",
        "time": "130万"
      }, {
        "images": "../../resource/images/song-list-2.jpg",
        "title": "网易云那些10至100w+评论的歌单按专辑排序",
        "time": "1953万"
      }, {
        "images": "../../resource/images/song-list-3.jpg",
        "title": "一起努力 做更好的自己",
        "time": "59.3亿"
      }, {
        "images": "../../resource/images/song-list-4.jpg",
        "title": "两个人互相惦念的见面才有意义",
        "time": "953万"
      }, {
        "images": "../../resource/images/song-list-5.jpg",
        "title": "神仙翻唱：超好听的女生翻唱集鸭",
        "time": "2072万"
      }]
    }, {
      classify: "精品",
      child: [{
        "images": "../../resource/images/song-list-1.jpg",
        "title": "行在路上 寻找旅途的秘境",
        "time": "130万"
      }, {
        "images": "../../resource/images/song-list-2.jpg",
        "title": "网易云那些10至100w+评论的歌单按专辑排序",
        "time": "1953万"
      }, {
        "images": "../../resource/images/song-list-3.jpg",
        "title": "一起努力 做更好的自己",
        "time": "59.3亿"
      }, {
        "images": "../../resource/images/song-list-4.jpg",
        "title": "两个人互相惦念的见面才有意义",
        "time": "953万"
      }, {
        "images": "../../resource/images/song-list-5.jpg",
        "title": "神仙翻唱：超好听的女生翻唱集鸭",
        "time": "2072万"
      }]
    }, {
      classify: "华语",
      child: [{
        "images": "../../resource/images/song-list-1.jpg",
        "title": "行在路上 寻找旅途的秘境",
        "time": "130万"
      }, {
        "images": "../../resource/images/song-list-2.jpg",
        "title": "网易云那些10至100w+评论的歌单按专辑排序",
        "time": "1953万"
      }, {
        "images": "../../resource/images/song-list-3.jpg",
        "title": "一起努力 做更好的自己",
        "time": "59.3亿"
      }, {
        "images": "../../resource/images/song-list-4.jpg",
        "title": "两个人互相惦念的见面才有意义",
        "time": "953万"
      }, {
        "images": "../../resource/images/song-list-5.jpg",
        "title": "神仙翻唱：超好听的女生翻唱集鸭",
        "time": "2072万"
      }]
    }, {
      classify: "流行",
      child: [{
        "images": "../../resource/images/song-list-1.jpg",
        "title": "行在路上 寻找旅途的秘境",
        "time": "130万"
      }, {
        "images": "../../resource/images/song-list-2.jpg",
        "title": "网易云那些10至100w+评论的歌单按专辑排序",
        "time": "1953万"
      }, {
        "images": "../../resource/images/song-list-3.jpg",
        "title": "一起努力 做更好的自己",
        "time": "59.3亿"
      }, {
        "images": "../../resource/images/song-list-4.jpg",
        "title": "两个人互相惦念的见面才有意义",
        "time": "953万"
      }, {
        "images": "../../resource/images/song-list-5.jpg",
        "title": "神仙翻唱：超好听的女生翻唱集鸭",
        "time": "2072万"
      }]
    }, {
      classify: "轻音乐",
      child: [{
        "images": "../../resource/images/song-list-1.jpg",
        "title": "行在路上 寻找旅途的秘境",
        "time": "130万"
      }, {
        "images": "../../resource/images/song-list-2.jpg",
        "title": "网易云那些10至100w+评论的歌单按专辑排序",
        "time": "1953万"
      }, {
        "images": "../../resource/images/song-list-3.jpg",
        "title": "一起努力 做更好的自己",
        "time": "59.3亿"
      }, {
        "images": "../../resource/images/song-list-4.jpg",
        "title": "两个人互相惦念的见面才有意义",
        "time": "953万"
      }, {
        "images": "../../resource/images/song-list-5.jpg",
        "title": "神仙翻唱：超好听的女生翻唱集鸭",
        "time": "2072万"
      }]
    }, {
      classify: "摇滚",
      child: [{
        "images": "../../resource/images/song-list-1.jpg",
        "title": "行在路上 寻找旅途的秘境",
        "time": "130万"
      }, {
        "images": "../../resource/images/song-list-2.jpg",
        "title": "网易云那些10至100w+评论的歌单按专辑排序",
        "time": "1953万"
      }, {
        "images": "../../resource/images/song-list-3.jpg",
        "title": "一起努力 做更好的自己",
        "time": "59.3亿"
      }, {
        "images": "../../resource/images/song-list-4.jpg",
        "title": "两个人互相惦念的见面才有意义",
        "time": "953万"
      }, {
        "images": "../../resource/images/song-list-5.jpg",
        "title": "神仙翻唱：超好听的女生翻唱集鸭",
        "time": "2072万"
      }]
    }, {
      classify: "民谣",
      child: [{
        "images": "../../resource/images/song-list-1.jpg",
        "title": "行在路上 寻找旅途的秘境",
        "time": "130万"
      }, {
        "images": "../../resource/images/song-list-2.jpg",
        "title": "网易云那些10至100w+评论的歌单按专辑排序",
        "time": "1953万"
      }, {
        "images": "../../resource/images/song-list-3.jpg",
        "title": "一起努力 做更好的自己",
        "time": "59.3亿"
      }, {
        "images": "../../resource/images/song-list-4.jpg",
        "title": "两个人互相惦念的见面才有意义",
        "time": "953万"
      }, {
        "images": "../../resource/images/song-list-5.jpg",
        "title": "神仙翻唱：超好听的女生翻唱集鸭",
        "time": "2072万"
      }]
    }],
    list: [],
  },
  // imgH(e){
  get_wxml(className, callback) {
    wx.createSelectorQuery().selectAll(className).boundingClientRect().exec(callback)
  },
  // }
  skip(e) {

    if (e.currentTarget.dataset.name == "官方") {
      wx.navigateTo({
        url: "../details/details"
      })
    }
  },
  upper(e) {

  },

  lower(e) {
 
  },

  scroll(e) {

  },

  scrollToTop() {
    this.setAction({
      scrollTop: 0
    })
  },

  tap() {
    for (let i = 0; i < order.length; ++i) {
      if (order[i] === this.data.toView) {
        this.setData({
          toView: order[i + 1],
          scrollTop: (i + 1) * 200
        })
        break
      }
    }
  },

  pathto(e){
   
    wx.navigateTo({
      url: `../details/details?id=${e.currentTarget.dataset.id}&songsheetCode=${e.currentTarget.dataset.songsheetcode}`,
    })
  },

  tapMove() {
    this.setData({
      scrollTop: this.data.scrollTop + 10
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.request({
      url: 'http://192.168.0.26:8081/songSheet/getManagementSongSheet',
      method: 'get',
      success: (res) => {
        if (res.data.data.imgUrl != "") {
          for (let i = 0; i < res.data.data.length; i++) {
            if (res.data.data[i].playNumber > 100000000) {
              res.data.data[i].playNumber = parseInt(res.data.data[i].playNumber / 10000000) + "亿"
            } else if (res.data.data[i].playNumber > 100000) {
              res.data.data[i].playNumber = parseInt(res.data.data[i].playNumber / 10000) + "万"
            }
    
            res.data.data[i].imgUrl =
              "http://192.168.0.26:8081" + res.data.data[i].imgUrl;

          }
        }
        this.setData({
          list: res.data.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})